import transformers


class Tokenizer:
    def __init__(self, pretrained_model_name_or_path, *inputs, **kwargs):
        if "openai/clip" in pretrained_model_name_or_path:
            tokenizer_builder = transformers.CLIPTokenizer
        else:
            tokenizer_builder = transformers.AutoTokenizer

        self.tokenizer = tokenizer_builder.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
    
    def __call__(self, texts, device='cpu'):
         return self.tokenizer(texts, 
                               return_tensors='pt', 
                               padding=True,
                               truncation=True)